/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.ArrayList;

/**
 *
 * @author SONY
 */
public class SaleOrderDetailService {
    
    SaleOrderDetailDAO saleOrderDetailDAO;
    
    public SaleOrderDetailService() {
        saleOrderDetailDAO = new SaleOrderDetailDAO();
    }
    
    public SaleOrderDetail addSaleOrderDetail(int SaleOrderID, String ProductID, int OrderQty, double LineTotal) {
        try {
            int saleorderdetailid = saleOrderDetailDAO.insert(SaleOrderID, ProductID, OrderQty, LineTotal);
            if (saleorderdetailid != -1) {
                SaleOrderDetail saleorderdetail = new SaleOrderDetail(saleorderdetailid, SaleOrderID, ProductID, OrderQty, LineTotal);
                return saleorderdetail;
            }
        } catch (Exception e) {
            System.err.println(e);
        }
        return null;
    }
    
    public ArrayList<SaleOrderDetail> getSaleOrderDetails_bySaleOrderID(int SaleOrderID) {
        ArrayList<SaleOrderDetail> lstSaleOrderDetails = new ArrayList<SaleOrderDetail>();
        try {
            lstSaleOrderDetails = saleOrderDetailDAO.search_bySaleOrderID(SaleOrderID);
            
        } catch(Exception e) {
            System.err.println(e);
        }
        return lstSaleOrderDetails;
    }
    
}
